﻿using System.Data;
using System.Data.SqlClient;

namespace Azalea.ORMap
{
    public class DbFactorySqlSvr : DbFactoryBase
    {
        public override string ParameterPrefix
        {
            get { return "@"; }
        }

        public override IDbConnection NewConnection()
        {
            return new SqlConnection();
        }

        public override IDbCommand NewCommand()
        {
            return new SqlCommand();
        }

        public override IDataAdapter NewDataAdapter(IDbCommand cmd)
        {
            return new SqlDataAdapter((SqlCommand) cmd);
        }

        public override IDataParameter NewParameter()
        {
            return new SqlParameter();
        }

        public override string Quoting(string word)
        {
            return string.Format("[{0}]", word);
        }

        public override string GetSqlStatementToGetSchema()
        {
            return
                "select name from sysobjects where (xtype='U' or xtype='V') and (name!='dtproperties' and name!='syssegments' and name!='sysconstraints')";
        }

        public override string GetFunctionNameToGetAutoIncrementValue()
        {
            return "SCOPE_IDENTITY";
        }
    }
}